<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增用况')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-usage-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">用况名称：</label>
                <div class="col-sm-8">
                    <input name="usageyName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">用况说明：</label>
                <div class="col-sm-8">
                    <textarea name="usageyDescription" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">用况接口：</label>
                <div class="col-sm-8">
                    <select name="interfaceId" id="interfaceId" class="form-control m-b">
                        <option value="0">无</option>
                        <option th:each="interfaceInfo : ${interfaceInfoList}" th:text="${interfaceInfo.interfaceName}" th:value="${interfaceInfo.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">用况类型：</label>
                <div class="col-sm-8">
                    <select name="usageType" id="usageType" class="form-control m-b" th:with="type=${@dict.getType('usageType')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">是否单模块用况：</label>
                <div class="col-sm-8">
                    <select name="isAlone" class="form-control m-b" th:with="type=${@dict.getType('sys_yes_no')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">用况故事：</label>
                <div class="col-sm-8">
                    <textarea name="usageStory" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">价值描述：</label>
                <div class="col-sm-8">
                    <textarea name="valueDescription" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">业务实现逻辑描述：</label>
                <div class="col-sm-8">
                    <textarea name="businessImplDescription" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">前后台类型：</label>
                <div class="col-sm-8">
                    <select name="fbType" class="form-control m-b" th:with="type=${@dict.getType('frontBackType')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">终端类型：</label>
                <div class="col-sm-8">
                    <select name="clientType" class="form-control m-b" th:with="type=${@dict.getType('terminalType')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">版本类型：</label>
                <div class="col-sm-8">
                    <select name="versionType" class="form-control m-b" th:with="type=${@dict.getType('versionType')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">优化或废弃说明：</label>
                <div class="col-sm-8">
                    <textarea name="versionDescription" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">分类节点：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="categoryId" name="categoryId" type="hidden" />
                        <input class="form-control" type="text" onclick="selectCategoryTree()" id="categoryName" readonly="true" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-xs-3 control-label">参与角色：</label>
                <div class="col-xs-8">
                    <select id="participateRoleId" class="form-control select2-multiple" multiple>
                        <option th:each="participateRole:${participateRoles}" th:value="${participateRole.id}" th:text="${participateRole.roleName}" th:disabled="${participateRole.status == '1'}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "usage/usage"
        $("#form-usage-add").validate({
            focusCleanup: true
        });

        $(function () {
            $('#participateRoleId').select2({
                placeholder: "请选择角色",
                allowClear: true
            });

            $("#interfaceId").select2({
                placeholder: "请选择",
                allowClear: true
            });
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $('#form-usage-add').serializeArray();
                var participateRoleIds = $.form.selectSelects("participateRoleId");
                data.push({"name": "participateRoleIds", "value": participateRoleIds});
                $.operate.save(prefix + "/add", data);
            }
        }

        var prefix2 = ctx + "category/category"
        /*分类体系-新增-选择父分类体系树*/
        function selectCategoryTree() {
            var options = {
                title: '分类体系选择',
                width: "380",
                url: prefix2 + "/selectCategoryTree2/0/3",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#categoryId").val(body.find('#treeId').val());
            $("#categoryName").val(body.find('#treeName').val());
            layer.close(index);
        }

    </script>
</body>
</html>